package com.rimi.controller;

import com.rimi.bean.Doctor;
import com.rimi.commons.CommonResult;
import com.rimi.service.DoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author liHaiYang
 * @version V1.0
 * @Description: (用一句话描述该文件做什么)
 * @date 2021/7/7 10:07
 */
@RestController
@CrossOrigin
@Api(description = "医生账号管理",tags = "医生账号管理")
public class DoctorController {

    @Autowired
    DoctorService doctorService;

    @PostMapping("doctor/add")
    @ResponseBody
    @ApiOperation("添加医生")
    public CommonResult add(@RequestBody Doctor doctor){
        return doctorService.addDoctor(doctor);
    }

    @GetMapping("doctor/show")
    @ResponseBody
    @ApiOperation("展示医生")
    public CommonResult<List<Doctor>> show(){
        List<Doctor> doctors = doctorService.showDoctor();
        return CommonResult.onSuccess(doctors);
    }

    @DeleteMapping("doctor/delete/{doctorId}")
    @ResponseBody
    @ApiOperation("删除医生")
    public CommonResult delete(@PathVariable Integer doctorId){
        return doctorService.deleteDoctorByDoctorId(doctorId);
    }

    @PutMapping("doctor/update/{doctor}")
    @ResponseBody
    @ApiOperation("编辑医生信息")
    public CommonResult update(@RequestBody Doctor doctor){
        return doctorService.updateDoctor(doctor);
    }
}
